﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Home.ShortNews.ascx.cs" Inherits="Controls_Home_ShortNews" %>
<div class="diembao" id="divShort">
    <div class="db_text">ĐIỂM BÁO</div>
    <div class="db_nd">
        <div class="db_nut" style="height: 26px;">
            <a href="javascript:;" onclick="javascript:showShortLong(this); return false;" id="hlShort" class="db_x"></a><a href="javascript:;" onclick="javascript:showShortLong(this); return false;">
                <img src="/resources/images/db.gif" border="0" id="arrowid"></a>
        </div>
        <div class="db_dong1" id="divFull" style="display:none;">
            <ul>
                <li><a href="javascript:;" onclick="javascript:prev();" class="db_k">
                    <img src="/resources/images/db_t.gif" border="0"></a></li>
                <li style="width: 450px; padding-bottom:10px;"><%--<a href="#" id="hlLong"></a>--%>
                    <p id="spSubhead" style="width: 455px;"></p>
                </li>
                <li><a href="javascript:;" onclick="javascript:next();" class="db_k">
                    <img src="/resources/images/db_l.gif" border="0"></a></li>
            </ul>
            <div class="clear"></div>
        </div>
    </div>
    <div class="clear"></div>
</div>

<%--<div class="diembao" >
    <div class="db_text">ĐIỂM BÁO</div>
    <div class="db_nd">
        <div class="db_nut">
            <a href="javascript:;" onclick="javascript:showShortLong(this); return false;">
                <img src="/resources/images/db_n.gif" border="0"></a>
        </div>
        

    </div>
    <!--end db_nd-->
    <div class="clear"></div>
</div>--%>
<!-- end box1 -->
<script type="text/javascript">    
    var jsonNews = <% =JsonShortNews%>;
    var index = 0;
    var shortInterval, longInterval;
    var type = 1;

    function showShortLong(e) {
        $('#divFull').slideToggle();
        $('#spSubhead').html(jsonNews[index].Lead);
        if (type == 1) {
            //$('#hlShort').html('');
            $('#arrowid').html('<img src="/resources/images/db_n.gif" border="0">');
            //$('#divShort').hide();
            type = 2;
            clearInterval(shortInterval);
            longInterval = setInterval(longShortNews, 5000);
        }
        else {
            $('#hlShort').html(jsonNews[index].Title.length > 60 ? jsonNews[index].Title.substring(0, 60) + '...' : jsonNews[index].Title);
            //$('#hlShort').attr('onclick', 'javascript:showShortLong();');
            $('#arrowid').html('<img src="/resources/images/db.gif" border="0">');
            //$('#divShort').show();
            type = 1;
            clearInterval(longInterval);
            shortInterval = setInterval(shortNews, 5000);
        }
    }
    function shortNews() {
        $('#hlShort').fadeOut(400, function () {
            //$('#hlShort').attr('href', jsonNews[index].Url);
            $(this).html(jsonNews[index].Title.length > 60 ? jsonNews[index].Title.substring(0,60) + '...' : jsonNews[index].Title).fadeIn(400);
        });
        index++;
        if (index > jsonNews.length - 1)
            index = 0;
    }
    function longShortNews() {
        $('#hlShort').fadeOut(400, function () {
            $(this).html(jsonNews[index].Title.length > 60 ? jsonNews[index].Title.substring(0,60) + '...' : jsonNews[index].Title).fadeIn(400);
            //$('#hlShort').attr('href', jsonNews[index].Url);
        });
        $('#spSubhead').fadeOut(400, function () {
            $(this).html(jsonNews[index].Lead).fadeIn(400);
        });
        index++;
        if (index > jsonNews.length - 1)
            index = 0;
    }
    function next() {
        index++;
        if (index > jsonNews.length - 1)
            index = 0;
        clearInterval(longInterval);
        $('#hlShort').fadeOut(400, function () {
            $(this).html(jsonNews[index].Title.length > 60 ? jsonNews[index].Title.substring(0,60) + '...' : jsonNews[index].Title).fadeIn(400);
            //$('#hlShort').attr('href', jsonNews[index].Url);
        });
        $('#spSubhead').fadeOut(400, function () {
            $(this).html(jsonNews[index].Lead).fadeIn(400);
        });
    }
    function prev() {
        index--;
        if (index < 0)
            index = jsonNews.length - 1;
        clearInterval(longInterval);
        $('#hlShort').fadeOut(400, function () {
            $(this).html(jsonNews[index].Title).fadeIn(400);
            //$('#hlShort').attr('href', jsonNews[index].Url);
        });
        $('#spSubhead').fadeOut(400, function () {
            $(this).html(jsonNews[index].Lead).fadeIn(400);
        });
    }

    $(document).ready(function () {
        shortNews();
        longShortNews();
        shortInterval = setInterval(shortNews,5000);
    });
    
</script>